//
//  HDMacro.h
//  HeartBeat
//
//  Created by karong on 2023/8/23.
//

#ifndef HDMacro_h
#define HDMacro_h

typedef void(^失败回调)(NSURLResponse *response, NSError *error, id responseObject);
typedef void(^空回调)(void);
typedef void(^回调一个对象)(id obj);
typedef void(^回调一个数组)(NSArray * array);
typedef void(^回调一个字符串)(NSString * string);
typedef void(^回调一个字典)(NSDictionary * dict);
typedef void(^回调一个数字)(NSInteger integer);
typedef void(^回调一个布尔)(BOOL rec);
typedef void(^回调一个数组和字典)(NSArray *array, NSDictionary *dict);
typedef void(^回调两个字符串)(NSString * string1, NSString * string2);

#define WeakSelf __weak typeof(self) weakSelf = self;

// 屏幕
#define HBScreenWidth           [UIScreen mainScreen].bounds.size.width
#define HBScreenHeight          [UIScreen mainScreen].bounds.size.height
#define HBStatusBarHeight       [[UIApplication sharedApplication] statusBarFrame].size.height
#define HBSafeAreaBottomHeight  [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom
// 設备
#define HBIsiPhoneX       (int)((kScreenHeight/kScreenWidth)*100) == 216.f

// 单例
#define SingletonH + (instancetype)shared;
#define SingletonM \
static id _instance; \
+ (instancetype)allocWithZone:(struct _NSZone *)zone \
{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _instance = [super allocWithZone:zone]; \
    }); \
    return _instance; \
} \
+ (instancetype)shared \
{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _instance = [[self alloc] init]; \
    }); \
    return _instance; \
} \
- (id)copyWithZone:(NSZone *)zone \
{ \
    return _instance; \
}
#define KIs32BitCPU      (sizeof(void*) == 4)
// 字符串格式化
#define SF(format, ...) ([NSString stringWithFormat:(format), ##__VA_ARGS__])
// 字符串非空判斷
#define KIsNullOrEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || str.length <= 0)
// 字符串空保护
#define KEmptyStr(str) KIsNullOrEmpty(str) ? @"" : str
// 讀取本地圖片
#define IMG(file) ([UIImage imageNamed:(file)])
#define appUserDefaults         [NSUserDefaults standardUserDefaults]
// 默認圖片
#define HBPlaceholderImage      [UIImage imageNamed:@"icon_tx_n"]
#define HBUserPlaceholderImage  [UIImage imageNamed:@"icon_tx_n"]
#define appUserCenter           [HBUserCenterModel defaultSession]
#define appConfig               [HBAppConfig defaultSession]
#define WSLocalized(key)        NSLocalizedString(key, nil)

#define NovelReadBgColor       @[@"FFF9EB", @"FFDAB3", @"D7DEFB", @"CAFDCB", @"1A1A1A"]

#define HB_FLYER_KEY        @"XuRufSZUWeYhaEydUh7xnJ"
#define HB_APPSTORY_ID      @"6466397214"
#define HB_FACEBOOK_ID      @"556608902904925"
#define HB_LINE_ID          @"1655266484"
/**
 Notification
 */
#define HBRefreshBookInfoNotification       @"HBRefreshBookInfoNotification"
#define HBRefreshChapterNotification        @"HBRefreshChapterNotification"
#define HBRefreshUserInfoNotification       @"HBRefreshUserInfoNotification"
#define HBRefreshFollowNotification         @"HBRefreshFollowNotification"

/**
 枚举
 */
typedef enum : NSUInteger {
    /// 横向水平滑动
    HBChannelConfigType1 = 1,
    /// 横向布局一行2个
    HBChannelConfigType2,
    /// Banner(656*300)
    HBChannelConfigType3,
    /// 运营位小喇叭
    HBChannelConfigType4,
    /// 排行榜
    HBChannelConfigType5,
} HBChannelConfig;

typedef enum : NSUInteger {
    HBMineItemTypeHDZX = 1, ///活動中心
    HBMineItemTypeWDPL,     ///我的評論
    HBMineItemTypeYDPH,     ///閱讀偏好
    HBMineItemTypeWDQB,     ///我的錢包
    HBMineItemTypeSZ,       ///設置
    HBMineItemTypeBZFK,     ///幫助反饋
} HBMineItemType;

typedef enum : NSUInteger {
    HBReadAlterTypePay = 1, ///解鎖
} HBReadAlterType;

typedef enum : NSUInteger {
    HBPurchaseStatusSuccess = 1,        // 成功
    HBPurchaseStatusCancel = 2,         // 取消
    HBPurchaseStatusFailed = 3,         // 失败
    HBPurchaseStatusVerifing = 4,       // 校验中
    HBPurchaseStatusVaildSuccess = 5,   // 校验成功
    HBPurchaseStatusVaildFailed = 6,    // 校验失败
    HBPurchaseStatusPaying = 7,         // 正在购买
    HBPurchaseStatusHaveNoVerify = 8,   // 未验证
    HBPurchaseStatusProductUnfinish = 9 // 未完成
} HBPurchaseStatus;

typedef enum : NSUInteger {
    /// 空状态
    HBListViewEmptyStateEmpty,
    /// 无网络
    HBListViewEmptyStateNoNetwork,
    /// 遊客
    HBListViewEmptyStateNoToken,
} HBListViewEmptyState;

typedef enum : NSUInteger {
    HBAlignWithLeft,
    HBAlignWithCenter,
    HBAlignWithRight
} HBAlignType;

//主题颜色
typedef enum : NSUInteger {
    HBReadColor_Yellow = 0,
    HBReadColor_Orange = 1,
    HBReadColor_Blue = 2,
    HBReadColor_Green = 3,
} HBReadColor;


//翻页样式
typedef enum : NSUInteger {
    HBBrowseType_Scroll = 0,    //滑動
    HBBrowseType_Cover = 1,     //覆蓋
    HBBrowseType_None = 2,      //无动画
} HBBrowseType;

//翻页样式
typedef NS_ENUM(NSUInteger,HBControllerJumpType){
    HBControllerJumpTypeNon = 0,                //无跳转
    HBControllerJumpTypeVip = 1,                //vip充值
    HBControllerJumpTypeCoin = 2,               //书币充值
    HBControllerJumpTypeForYou = 3,             //首页推荐
    HBControllerJumpTypeFemale = 4,             //首页女频
    HBControllerJumpTypeMale = 5,               //首页男频
    HBControllerJumpTypeUser = 6,               //个人信息
    HBControllerJumpTypeFollow = 7,             //追书
    HBControllerJumpTypeNovel = 8,              //小說
    HBControllerJumpTypeUrl = 9,                //外鏈
    HBControllerJumpTypeRankFemale = 10,        //排行榜女頻
    HBControllerJumpTypeRankMale = 11,          //排行榜男頻
};

//埋点类型
typedef enum : NSUInteger {
    HBEvenLogType_Click = 0,    //点击
    HBEvenLogType_Show = 1,     //曝光
    HBEvenLogType_Pop = 2,      //可视化曝光
} HBEvenLogType;
#endif /* HDMacro_h */
